package com.examplemartin.jpademo.pojo.po.stock;

import com.examplemartin.jpademo.annotation.EntityCheck;
import com.examplemartin.jpademo.pojo.admin.BaseEntity;
import com.examplemartin.jpademo.pojo.po.UserPO;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 仓库实体
 */

@Data
@EqualsAndHashCode(callSuper = true)
@Entity(name = "t_stock")
public class StockPO extends BaseEntity implements Serializable {

  @EntityCheck(required = true,errRequired = "必须填写仓库名")
  private String name;
  @EntityCheck(required = true,errRequired = "必须填写地址")
  private String address;
  @EntityCheck(required = true,errRequired = "必须填写联系人")
  private String linkman;
  private String phone;
  private String email;
  private String comment;

  // 仓管员 list
  @OneToMany(mappedBy = "stockPO")
  @JsonIgnore
  private List<UserPO> userPOList;

  // 库存信息 list
  @OneToMany(mappedBy = "stockPO")
  @JsonIgnore
  private List<RepoInfoPO> repoInfoPOList;

  @Override
  public String toString() {
    return "StockPO{" +
            "name='" + name + '\'' +
            ", address='" + address + '\'' +
            ", linkman='" + linkman + '\'' +
            ", phone='" + phone + '\'' +
            ", email='" + email + '\'' +
            ", comment='" + comment + '\'' +
            '}';
  }
}
